#ifndef SMOOTHWINDOWSIZEANIMATION_H
#define SMOOTHWINDOWSIZEANIMATION_H

#include <windows.h>
#include <WindowsX.h>
#include <map>

class SmoothWindowSizeAnimation;

#include "Utilities.h"
#include "SmoothWindowSideAnimation.h"

using namespace std;

class SmoothWindowSizeAnimation
{
public:
	typedef void (*WNDSIZEANIMATIONPROC)(SmoothWindowSizeAnimation* sender);

	SmoothWindowSizeAnimation(HWND hWnd);
	~SmoothWindowSizeAnimation();
	
	HWND GetHWnd();
	bool IsRunning();
	bool StartAnimation(int cxSpeed, int cySpeed, SIZE startSize, SIZE endSize, bool widthFirst);
	void CancelAnimation();

	void AnimationStarted(WNDSIZEANIMATIONPROC ptr);
	void AnimationCancelled(WNDSIZEANIMATIONPROC ptr);
	void AnimationFinished(WNDSIZEANIMATIONPROC ptr);
private:
	void StartWidthAnimation();
	void StartHeightAnimation();

	int cxSpeed;
	int cySpeed;
	SIZE startSize;
	SIZE endSize;
	bool widthFirst;

	SmoothWindowSideAnimation* widthAnimation;
	SmoothWindowSideAnimation* heightAnimation;

	HWND hWnd;
	int instanceId;

	WNDSIZEANIMATIONPROC onAnimationStartedPtr;
	WNDSIZEANIMATIONPROC onAnimationCancelledPtr;
	WNDSIZEANIMATIONPROC onAnimationFinishedPtr;

	void CallWndSizeAnimationEvent(WNDSIZEANIMATIONPROC ptr);

	static map<int, SmoothWindowSizeAnimation*> instances;
	static int instanceCounter;


	static void heightAnimation_ValueChanged(SmoothWindowSideAnimation* sender, int step, int currentValue, LPVOID tag);
	static void widthAnimation_ValueChanged(SmoothWindowSideAnimation* sender, int step, int currentValue, LPVOID tag);
		
	static void widthAnimation_AnimationFinished(SmoothWindowSideAnimation* sender, LPVOID tag);
	static void widthAnimation_AnimationStarted(SmoothWindowSideAnimation* sender, LPVOID tag);
	
	static void heightAnimation_AnimationStarted(SmoothWindowSideAnimation* sender, LPVOID tag);
	static void heightAnimation_AnimationFinished(SmoothWindowSideAnimation* sender, LPVOID tag);
	
};

#endif